/**
 * 
 */
package com.atjava.nebula.core.constant;

import com.atjava.nebula.core.util.func.ClassLoaderUtil;


/**用于读取项目基础常量
 * @author kyo
 *
 */
public class ProjectConstant implements Constant{
	
	private static String realPath;
	private static String URLEncoding;
	
	/**取得项目的实际路径
	 * @return 返回路径字符串
	 */
	public static String getPath(){
		
		if(realPath==null){
			//throw new RuntimeException("项目的路径信息为空，无法取得");
			try {
				realPath=ClassLoaderUtil.getExtendResource("../../").getPath();
			} catch (Exception e) {
				e.printStackTrace();
			}
			//realPath="WebRoot/";
		}
		return realPath;
	}

	public static  void setPath(String path)
	{	
		realPath = path;
	}
	
	public static void setURLEncoding(String urlEncoding)
	{
		URLEncoding = urlEncoding;
	}
	
	/**取得Web容器对URL进行的编码方式
	 * @return 返回字符串，如"UTF-8","ISO-8859-1"
	 */
	public static String getURLEncoding()
	{
		if(URLEncoding == null)
			URLEncoding = "ISO-8859-1";
		return URLEncoding;
	}
	
}
